<?php

    $link = @mysqli_connect("localhost:3306","root","root","xmyp");

    if(!$link){
        $data = array("code"=>0,"errMsg"=>"数据库连接失败","sucMsg"=>"");
        die(json_encode($data));
    }

    $sql = "SELECT * FROM banner";

    $res = mysqli_query($link,$sql);

    if($res){
        $dataArr=array();
        while(true){
            $d = mysqli_fetch_assoc($res);
            if(!$d){
                break;
            }
            array_push($dataArr,$d);
        }
        echo(json_encode($dataArr));
    }else{
        $backData = array("code"=>1,"errMsg"=>"请求失败","sucMsg"=>"");
        echo(json_encode($backData));
    }

    mysqli_close($link);

?>
